<%-- 
    Document   : init
    Created on : 21-nov-2009, 22:05:38
    Author     : Roelie
--%>

<%@page import="be.ugent.medirem.logic.*, javax.naming.*, be.ugent.medirem.persistence.entity.details.*"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%!    private GpRemote gpRemote = null;
       private PatientRemote patientRemote = null;

    public void jspInit() {
        try {
            Context c = new InitialContext();
            gpRemote = (GpRemote) c.lookup("java:comp/env/GpBean");
            patientRemote = (PatientRemote) c.lookup("java:comp/env/PatientBean");

            // Add some GPs
            Long gp1 = gpRemote.create(new GpDetails("test", "Doctor Simon", "Buelens"), "test");
            gpRemote.create(new GpDetails("test2", "Doctor Roelie", "Roelens"), "ja");

            // Add locations
            LocationDetails loc = new LocationDetails("Toffe straat", 1, 9000, "Gent", "Belgie", "09/3123145", "juij@tof.be");
            gpRemote.updateGpLocation(gp1, null, loc);

            // Ga niet want je moet gp zijn...
            //patientRemote.createPatient("patient", "test", "012312124");

        } catch (Exception ex) {
            System.out.println("Error");
        }
    }

    public void jspDestroy() {
        gpRemote = null;
        patientRemote = null;
    }

%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Init gps...</h1>
        <form action="init.jsp">
            <button type="submit" onclick="<% jspInit(); %>">Init</button>
        </form>
        <a href="index.jsp">Back to index</a>
    </body>
</html>
